import Vue from 'vue'
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

export const constantRouterMap = [
  {path: '/login', component: () => import(/* webpackChunkName: "about" */ '../components/pages/Login.vue'), hidden: true},
  // {path: '/404', component: () => import(/* webpackChunkName: "404" */ '../components/pages/404.vue'), hidden: true},
  {
    path: '/',
    component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
    redirect: '/welcome',
    name: '首页',
    hidden: true,
    children: [{
      path: 'welcome', 
      component: () => import(/* webpackChunkName: "about" */ '../components/pages/Welcome.vue'),
      meta: {title: '系统首页'},
    }]
  },
]

export default new VueRouter({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // 系统模块
  {
    path: '/system',
    name: '系统管理',
    component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),    
    meta: {title: '系统管理', icon: 'icon-xitongguanli'},
    children: [
      {
        path: '/system/account',
        name: '账号管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/account.vue'),
        meta: {title: '账号管理', icon: 'icon-zhanghaoguanli'},
        menu: 'account'
      },
      {
        path: '/system/user',
        name: '角色管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/user.vue'),
        meta: {title: '角色管理', icon: 'icon-jiaoseguanli'},
        menu: 'user'
      },
      {
        path: '/system/backmenu',
        name: '菜单管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/backmenu.vue'),
        meta: {title: '菜单管理', icon: 'icon-houtaicaidan'},
        menu: 'backmenu'
      },
      {
        path: '/system/areano',
        name: '地区管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/areano.vue'),
        meta: {title: '地区管理', icon: 'icon-diquguanli'},
        menu: 'areano'
      },
      {
        path: '/system/parameter',
        name: '参数管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/parameter.vue'),
        meta: {title: '参数管理', icon: 'icon-zhongduancanshuguanli'},
        menu: 'parameter'
      },
      {
        path: '/system/logs',
        name: '操作日志',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/system/logs.vue'),
        meta: {title: '操作日志', icon: 'icon-rizhiguanli5'},
        menu: 'logs'
      }
    ]
  },
  // 运营模块
  {
    path: '/operation',
    name: '运营管理',
    component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
    meta: {title: '运营管理', icon: 'icon-crew_operating'},
    children: [
      {
        path: '/operation/sp',
        name: 'sp管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/operation/sp.vue'),
        meta: {title: 'sp管理', icon: 'icon-SPorder'},
        menu: 'sp'
      },
      {
        path: '/operation/mac',
        name: 'mac管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/operation/mac.vue'),
        meta: {title: 'mac管理', icon: 'icon-SPorder'},
        menu: 'mac'
      }
    ]
  },
  // 审核中心模块
  {
    path: '/audit',
    name: '审核中心',
    component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
    meta: {title: '审核中心', icon: 'icon-shenhe'},
    children: [
      {
        path: '/audit/application',
        name: '应用审核',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/audit/application.vue'),
        meta: {title: '应用审核', icon: 'icon-yingyong'},
        menu: 'application'
      }
    ]
  },
  // 审核管理中心模块
  {
    path: '/management',
    name: '应用管理中心',
    component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
    meta: {title: '审核管理中心', icon: 'icon-qunfengguanlizhongxin'},
    children: [
      {
        path: '/management/classify',
        name: '应用分类管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/management/classify.vue'),
        meta: {title: '应用分类管理', icon: 'icon-ziyuan'},
        menu: 'classify'
      },
      {
        path: '/management/appmanage',
        name: '应用管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/management/appmanage.vue'),
        meta: {title: '应用管理', icon: 'icon-gaiicon-'},
        menu: 'appmanage'
      },
      {
        path: '/management/devapp',
        name: '开发者应用管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/management/devapp.vue'),
        meta: {title: '开发者应用管理', icon: 'icon-kaifazhezhongxin'},
        menu: 'devapp'
      },
      {
        path: '/management/updevapp',
        name: '上传开发者应用',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/management/updevapp.vue'),
        meta: {title: '上传开发者应用', icon: 'icon-shangchuan'},
        menu: 'updevapp'
      },
      {
        path: '/management/updeteordelete',
        name: '应用强制升级/卸载管理',
        component: () => import(/* webpackChunkName: "about" */ '../components/pages/management/updeteordelete.vue'),
        meta: {title: '应用强制升级/卸载管理', icon: 'icon-ziyuan1'},
        menu: 'updeteordelete'
      },
    ]
  },

  {path: '*', redirect: '/404', hidden: true}

  // {
  //   path: '/',
  //   component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
  //   name: '用户管理',
  //   meta: {title: '用户权限', icon: 'table'},
  //   children: [
  //     {
  //       path: 'user', 
  //       name: '用户列表',
  //       component: () => import(/* webpackChunkName: "about" */ '../components/pages/Users.vue'),
  //       meta: {title: '用户列表', icon: 'user'}, 
  //       menu: 'user'
  //     },
  //     {
  //       path: 'role',
  //       name: '权限管理',
  //       component: () => import(/* webpackChunkName: "about" */ '../components/pages/Roles.vue'),
  //       meta: {title: '权限管理', icon: 'password'},
  //       menu: 'role'
  //     },
  //   ]
  // },
  // {
  //   path: '',
  //   component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
  //   name: '用户',
  //   meta: {title: '用户', icon: 'table'},
  //   children: [
  //     {
  //       path: 'userone', name: '用户One',  
  //       component: () => import(/* webpackChunkName: "about" */ '../components/pages/yonghu/yonghuOne.vue'), meta: {title: '用户One', icon: 'user'}, menu: 'user'
  //     },
  //     {
  //       path: 'roleone',
  //       name: '用户two',
  //       component: () => import(/* webpackChunkName: "about" */ '../components/pages/yonghu/yonghuSecond.vue'),
  //       meta: {title: '用户two', icon: 'password'},
  //       menu: 'role'
  //     },
  //   ]
  // },
  // {
  //   path: '//',
  //   component: () => import(/* webpackChunkName: "about" */ '../components/pages/Home.vue'),
  //   name: '系统模块',
  //   meta: {title: '用户权限', icon: 'table'},
  //   children: [
  //     {
  //       path: 'user', name: '用户列表', component: () => import(/* webpackChunkName: "about" */ '../components/pages/Welcome.vue'), meta: {title: '用户列表', icon: 'user'}, menu: 'bbc'
  //     },
  //     {
  //       path: 'role',
  //       name: '账号模块',
  //       component: () => import(/* webpackChunkName: "about" */ '../components/pages/account/accountOne.vue'),
  //       meta: {title: '账号模块', icon: 'password'},
  //       menu: 'role'
  //     },
  //   ]
  // },
]
